package com.dongjiantong.sys.serviceImpl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongjiantong.mybatis.ServiceMybatis;
import com.dongjiantong.sys.mapper.DicDataMapper;
import com.dongjiantong.sys.model.DicData;
import com.dongjiantong.sys.service.DicDataService;
import lombok.extern.slf4j.Slf4j;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author cao
 * @create 2017-11-28 上午9:42
 **/
@Slf4j
@Service(version = "1.0.0")
public class DicDataServiceImpl extends ServiceMybatis<DicData> implements DicDataService {

    @Resource
    private DicDataMapper dicDataMapper;


    @Override
   public List<DicData> queryDicByGroup(String groupCode)
   {
       Example example = new Example(DicData.class);

       Example.Criteria criteria= example.createCriteria();
       criteria.andEqualTo("dicGroup",groupCode);
       criteria.andEqualTo("deleteFlag",1);

       return dicDataMapper.selectByExample(example);
   }

   @Override
    public DicData queryDicByGroupAndValue(String groupCode,String dicValue)
    {

        DicData dicData = new DicData();
        dicData.setDeleteFlag(1);
        dicData.setDicGroup(groupCode);
        dicData.setDicValue(dicValue);
        dicData.setIsfixed(1);

        return dicDataMapper.selectOne(dicData);
    }

    /**
     * 取系统模块
     * @return
     */
    @Override
    public List<DicData> queryGlobalModule()
    {
        return queryDicByGroup("global_module");
    }

    /**
     * 取APP角色
     * @return
     */
    @Override
    public List<DicData> queryAPPRole()
    {
        return queryDicByGroup("app_role");
    }

    /**
     * 取企业类型
     * @return
     */
    @Override
    public List<DicData> queryFarmsType()
    {
        return  queryDicByGroup("farms_type");
    }

}
